using Coding4Fun.Phone.Controls.Data;
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
namespace Coding4Fun.Phone.Controls
{
	public class AboutPrompt : ActionPopUp<object, PopUpResult>
	{
		public static readonly DependencyProperty IsPromptModeProperty = DependencyProperty.Register("IsPromptMode", typeof(bool), typeof(AboutPrompt), new PropertyMetadata(true, new PropertyChangedCallback(AboutPrompt.OnIsPromptModeChanged)));
		public static readonly DependencyProperty WaterMarkProperty = DependencyProperty.Register("WaterMark", typeof(object), typeof(AboutPrompt), new PropertyMetadata(null));
		public static readonly DependencyProperty VersionNumberProperty = DependencyProperty.Register("VersionNumber", typeof(object), typeof(AboutPrompt), new PropertyMetadata("v" + PhoneHelper.GetAppAttribute("Version").Replace(".0.0", "")));
		public static readonly DependencyProperty BodyProperty = DependencyProperty.Register("Body", typeof(object), typeof(AboutPrompt), new PropertyMetadata(null));
		public static readonly DependencyProperty FooterProperty = DependencyProperty.Register("Footer", typeof(object), typeof(AboutPrompt), new PropertyMetadata(null));
		public static readonly DependencyProperty TitleProperty = DependencyProperty.Register("Title", typeof(string), typeof(AboutPrompt), new PropertyMetadata(PhoneHelper.GetAppAttribute("Title")));
		public bool IsPromptMode
		{
			get
			{
				return (bool)base.GetValue(AboutPrompt.IsPromptModeProperty);
			}
			set
			{
				base.SetValue(AboutPrompt.IsPromptModeProperty, value);
			}
		}
		public object WaterMark
		{
			get
			{
				return base.GetValue(AboutPrompt.WaterMarkProperty);
			}
			set
			{
				base.SetValue(AboutPrompt.WaterMarkProperty, value);
			}
		}
		public string VersionNumber
		{
			get
			{
				return (string)base.GetValue(AboutPrompt.VersionNumberProperty);
			}
			set
			{
				base.SetValue(AboutPrompt.VersionNumberProperty, value);
			}
		}
		public object Body
		{
			get
			{
				return base.GetValue(AboutPrompt.BodyProperty);
			}
			set
			{
				base.SetValue(AboutPrompt.BodyProperty, value);
			}
		}
		public object Footer
		{
			get
			{
				return base.GetValue(AboutPrompt.FooterProperty);
			}
			set
			{
				base.SetValue(AboutPrompt.FooterProperty, value);
			}
		}
		public string Title
		{
			get
			{
				return (string)base.GetValue(AboutPrompt.TitleProperty);
			}
			set
			{
				base.SetValue(AboutPrompt.TitleProperty, value);
			}
		}
		public AboutPrompt()
		{
			base.set_DefaultStyleKey(typeof(AboutPrompt));
			RoundButton roundButton = new RoundButton();
			roundButton.add_Click(new RoutedEventHandler(this.method_5));
			base.ActionPopUpButtons.Add(roundButton);
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.SetIsPromptMode(this.IsPromptMode);
		}
		private static void OnIsPromptModeChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			AboutPrompt aboutPrompt = (AboutPrompt)dependencyObject_0;
			if (aboutPrompt != null && aboutPrompt.ActionButtonArea != null && dependencyPropertyChangedEventArgs_0.get_NewValue() != dependencyPropertyChangedEventArgs_0.get_OldValue())
			{
				aboutPrompt.SetIsPromptMode((bool)dependencyPropertyChangedEventArgs_0.get_NewValue());
			}
		}
		private void SetIsPromptMode(bool bool_3)
		{
			if (this.ActionButtonArea != null)
			{
				this.ActionButtonArea.set_Visibility(bool_3 ? 0 : 1);
			}
		}
		private void method_5(object sender, RoutedEventArgs e)
		{
			this.OnCompleted(new PopUpEventArgs<object, PopUpResult>
			{
				PopUpResult = PopUpResult.Ok
			});
		}
		public void Show(string authorName, string twitterName = null, string emailAddress = null, string websiteUrl = null)
		{
			List<AboutPersonItem> list = new List<AboutPersonItem>();
			list.Add(new AboutPersonItem
			{
				Role = "me",
				AuthorName = authorName
			});
			List<AboutPersonItem> list2 = list;
			if (!string.IsNullOrEmpty(twitterName))
			{
				list2.Add(new AboutPersonItem
				{
					Role = "twitter",
					WebSiteUrl = "http://www.twitter.com/" + twitterName.TrimStart(new char[]
					{
						'@'
					})
				});
			}
			if (!string.IsNullOrEmpty(websiteUrl))
			{
				list2.Add(new AboutPersonItem
				{
					Role = "web",
					WebSiteUrl = websiteUrl
				});
			}
			if (!string.IsNullOrEmpty(emailAddress))
			{
				list2.Add(new AboutPersonItem
				{
					Role = "email",
					EmailAddress = emailAddress
				});
			}
			this.Show(list2.ToArray());
		}
		public void Show(params AboutPersonItem[] people)
		{
			if (people != null && people.Length > 0)
			{
				StackPanel stackPanel = new StackPanel();
				stackPanel.set_HorizontalAlignment(3);
				stackPanel.set_VerticalAlignment(3);
				StackPanel stackPanel2 = stackPanel;
				for (int i = people.Length - 1; i >= 0; i--)
				{
					stackPanel2.get_Children().Insert(0, people[i]);
				}
				this.Body = stackPanel2;
			}
			base.Show();
		}
	}
}
